var sun = {};
var ref;
var network;
sun.createLink = function(param) {
	//	if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
	//		mui.toast("当前网络不给力，无法连接云端数据库~");
	//	} else {
	//		network = true;
	if (!app.getUser()) {
		mui.toast("用户信息丢失，请重新登录！");
	}
	ref = new Wilddog("https://sunafei.wilddogio.com" + param);
	//	}
	return ref;
}

sun.print = function(param) {
	mui.toast(param);
}

sun.push = function(module, params) {
	if(!app.getState().id()) {
		sun.print("信息丢失,无法新增！")
	}
	params.userkey = app.getState().account;
	ref = sun.createLink(module);
	ref.push(params);
}

//深度克隆
sun.cloneObj = function(obj) {
	var str, newobj = obj.constructor === Array ? [] : {};
	if(typeof obj !== 'object') {
		return;
	} else if(window.JSON) {
		str = JSON.stringify(obj), //序列化对象
			newobj = JSON.parse(str); //还原
	} else {
		for(var i in obj) {
			newobj[i] = typeof obj[i] === 'object' ? cloneObj(obj[i]) : obj[i];
		}
	}
	return newobj;
};